Skip to content

fix: pass column expressions through RetrieveAsync - #92

Merged
Aagaard00 merged 2 commits into
mainfrom
fix/retrieveAsyncColumnSet
Nov 25, 2026
Merged

Aagaard00 merged 2 commits into
mainfrom
fix/retrieveAsyncColumnSet

Conversation

@Anders-Toegersen

Copy link
Copy Markdown

Problem

RetrieveAsync<T>(id, params columnExpressions) and RetrieveWithCtAsync<T>(id, ct, params columnExpressions) never forward columnExpressions to RetrieveCoreAsync. Every call therefore falls back to ColumnSet(true) and retrieves all columns, whatever the caller asked for. RetrieveCachableAsync and RetrieveCachableWithCtAsync delegate to these methods, so they have the same problem.

The bug came in with #86. The sync Retrieve<T> is not affected.

Impact: a caller that wants two columns from a wide table, such as msdyn_workorder or account, pulls the whole row on every call.

Fix

  • Forward columnExpressions from both public methods.
  • Change the RetrieveCoreAsync parameter to Expression<Func<T, object?>>[] so it matches the public signatures.

Verification

  • The Release build of templatecompanyname.slnx passes with 0 warnings.
  • I checked it with a temporary XrmMockup test that was not committed, because the template ships without test classes:
    • RetrieveAsync<Contact>(id, c => c.FirstName) should return no lastname. This fails on main and passes with the fix.
    • RetrieveWithCtAsync<Contact>(id, ct, c => c.LastName) should return no firstname. This fails on main and passes with the fix.
    • RetrieveAsync<Contact>(id) with no columns still returns all columns, on both main and the fix.

RetrieveAsync and RetrieveWithCtAsync dropped columnExpressions before RetrieveCoreAsync, so every call fell back to ColumnSet(true). RetrieveCachableAsync variants inherited it.

@Aagaard00 Aagaard00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Aagaard00
Aagaard00 merged commit d091f7a into main Nov 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants